package com.collect.collectclient.utils;

import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.springframework.http.MediaType;
import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;

import java.util.Collections;

public class CustomXmlMessageConverter extends MappingJackson2XmlHttpMessageConverter {

    public CustomXmlMessageConverter() {
        super(createXmlMapper());
        setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_XML));
    }

    private static XmlMapper createXmlMapper() {
        XmlMapper xmlMapper = new XmlMapper();
        // 设置首字母大写的命名策略
        xmlMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
        return xmlMapper;
    }
}
